define(function(require, exports, module) {

  // var Backbone = require('backbone');
  var $ = require('jquery');
  var _ = require('underscore');
  // var jsonview = require('jsonview');
  var tmpl = require('text!../tmpl.html');

  var t = require('test')
  require('css!hy5b/t/test.css')

  function main() {
    var $app = $('<div id="app">');
    $('#main').html($app);

    $app.append(tmpl);

    function _onevent(eve) {
      t.S(eve.type, eve.offsetX, eve.offsetY);

      eve.stopImmediatePropagation();
      eve.stopPropagation();
      eve.preventDefault();
    }

    function _ontouchevent(eve) {
      t.S(eve.type, eve.touches.length);
      eve.stopImmediatePropagation();
      eve.stopPropagation();
      eve.preventDefault();
    }

    var root = document.getElementById('aa');
    root.addEventListener('dblclick', _onevent);
    root.addEventListener('mousewheel', _onevent);
    root.addEventListener('mousemove', _onevent);
    root.addEventListener('mousedown', _onevent);
    root.addEventListener('mouseup', _onevent);
    root.addEventListener('click', _onevent);

    root.addEventListener('DOMMouseScroll', _onevent);
    root.addEventListener('mouseout', _onevent);

    root.addEventListener('touchstart', _ontouchevent);
    root.addEventListener('touchmove', _ontouchevent);
    root.addEventListener('touchend', _ontouchevent);
    root.addEventListener('touchcancel', _ontouchevent);


    $('#task-list li').click(function() {
      t.S('click', 'li')
    });

    $('#task-list input[type="checkbox"]').click(function() {
      t.S('click', 'input')

    }).change(function() {
      t.S('change')
    })

    document.addEventListener("fullscreenchange", function(e) {
      console.log("fullscreenchange", e);
    });
    document.addEventListener("mozfullscreenchange", function(e) {
      console.log("mozfullscreenchange ", e);
    });
    document.addEventListener("webkitfullscreenchange", function(e) {
      console.log("webkitfullscreenchange", e);
    });
    document.addEventListener("msfullscreenchange", function(e) {
      console.log("msfullscreenchange", e);
    });
  }

  return main;
})
